<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>

    <div id="form">
        <div class="name">
            <label>用户名:</label>
            <input type="text" name="username" id="username">
        </div>
        <div class="password">
            <label>密码:</label>
            <input type="password" name="password" id="password">
        </div>
        <div id="errormessage"></div>
        <button type="button" id="denglubutton">登陆</button>
    </div>
    <div id="res"></div>

    <script>
        $("#denglubutton").click(function () {
            $.post("login",
                //发送给后端的数据
                {
                    "username": $("#username").val(),
                    "password": $("#password").val()
                },
                //回调函数
                function (data) {
                    $("#form").hide();
                    $("#res").append(data);
                    $("#res").show();
                }
            )
        })
    </script>
</body>
</html>